const SOURCE_STATUS = (value) => {
    switch (value) {
        case -1:
            return '已删除'
        case 0:
            return '待审核'
        case 1:
            return '已拒绝'
        case 3:
            return '进行中'//报价中
        case 4:
            return '已关闭'
        case 5:
            return '已完结'
        default:
            break;
    }
}

const SOURCE_DETAIL_STATUS = (value) => {
    switch (value) {
        case -1:
            return '已删除'
        case 0:
            return '待审核'
        case 1:
            return '已拒绝'
        case 2:
            return '已撤销'//待执行
        case 3:
            return '进行中'//报价中
        case 4:
            return '已关闭'
        case 5:
            return '已完结'
        case 6:
            return '已撤销'
        default:
            break;
    }
}

const ORDER_SOURCE_STATUS = (value) => {
    switch (value) {
        case 0:
            return '派单中'//派单中
        case 1:
            return '已关闭'
        case 2:
            return '已完结'
        case 3:
            return '已删除'
        default:
            break;
    }
}

const ORDER_STATUS = (value) => {
    switch (value) {
        case -1:
            return '已取消'
        case 0:
            return '待接单'
        case 1:
            return '待装货'
        case 2:
            return '运输中'
        case 3:
            return '待审核'
        case 4:
            return '已签收'
            case 5:
            return '已完成'
        default:
            break;
    }
}


const ORDER_STATUS_CH = (value) => {
    switch (value) {
        case -1:
            return '已取消'
        case 0:
            return '待接单'
        case 1:
            return '待装货'
        case 2:
            return '运输中'
        case 3:
            return '待审核'
        case 4:
            return '已签收'
            case 5:
            return '已完成'
        default:
            break;
    }
}

const REGIST_STATUS = (value) => {
    switch (value) {
        case 0:
            return '未认证'
        case 1:
            return '已认证'
        case 2:
            return '审核中'
        default:
            break;
    }

}

// 车牌颜色
const VEHICLE_COLOR = (value) => {
    if (value) {
        let vehicle = JSON.parse(window.localStorage.getItem("color_type"));
        let text = ""
        vehicle.forEach((item) => {
            if (item.value == value) {
                text = item.description
            }
        })
        return text
    }

}


// let vehicle_length_type = []
// let a = window.localStorage.getItem("vehicle_length_type");
// console.log(a)
// if (null != window.localStorage.getItem("vehicle_length_type") && window.localStorage.getItem("vehicle_length_type") != "undefined") {
//     vehicle_length_type = JSON.parse(window.localStorage.getItem("vehicle_length_type") || [])
// }



const BANK_CARD_TYPE = (value) => {
    if (value) {
        let vehicle_length_type = JSON.parse(window.localStorage.getItem("bank_card_type")) || []
        const arr = vehicle_length_type.filter(item => {
            if (item.value == value) {
                return item.description
            }
        })
        console.log(arr);
        return arr[0].description
    }

}


const VEHICLE_LENGTH_TYPE = (value) => {
    let vehicle_length_type = JSON.parse(window.localStorage.getItem("vehicle_length_type")) || []
    const arr = vehicle_length_type.filter(item => {
        return item.value == value
    })
    return arr.length > 0 ? arr[0].description : ''
}


const MODEL_REQUIRED = (value) => {
    if (value != null) {
        let ser = value.split(",").map(Number)
        let arr = []
        let vehicle_type = JSON.parse(window.localStorage.getItem("vehicle_type")) || []
        vehicle_type.forEach(element => {
            ser.forEach(item => {
                if (element.value == item) {
                    arr.push(element.description)
                }
            })
        });
        return arr.join(',')
    }
}
// let vehicle_type = []
// if (null != window.localStorage.getItem("vehicle_type") && window.localStorage.getItem("vehicle_type") != "undefined") {
//     vehicle_type = JSON.parse(window.localStorage.getItem("vehicle_type") || [])
// }
const VEHICLE_TYPE = (value) => {
    let vehicle_type = JSON.parse(window.localStorage.getItem("vehicle_type")) || []
    let arr = vehicle_type.filter(item => {
        return item.value == value
    })
    return arr.length > 0 ? arr[0].description : ''
}

const REQUIRED_VEHILE_LENGTH = (value) => {
    if (value != null) {
        let ser = value.split(",").map(Number)
        let arr = []
        let vehicle_length_type = JSON.parse(window.localStorage.getItem("vehicle_length_type")) || []
        vehicle_length_type.forEach(element => {
            ser.forEach(item => {
                if (element.value == item) {
                    arr.push(element.description)
                }
            })
        });
        return arr.join(',')
    }
}

const BUSINESS_TYPE = (value) => {
    // let arr = []
    // let good_new_type = JSON.parse(window.localStorage.getItem("good_new_type")) || []
    // good_new_type.forEach(element => {
    //     ser.forEach(item => {
    //         if (element.value == item) {
    //             arr.push(element.description)
    //         }
    //     })
    // });

    return
}

const GOOD_NEY_TYPE = (value) => {
    let ser = value.split(",").map(Number)
    let arr = []
    let good_new_type = JSON.parse(window.localStorage.getItem("good_new_type")) || []
    good_new_type.forEach(element => {
        ser.forEach(item => {
            if (element.value == item) {
                arr.push(element.description)
            }
        })
    });
    return arr.join(',')
}


const GOOD_NEY_TYPE_CARRY = (value) => {
    let arr = []
    let good_new_type = JSON.parse(window.localStorage.getItem("good_new_type")) || []
    good_new_type.forEach(element => {
        if (element.value == value) {
            arr.push(element.description)
        }
    });
    return arr.join(',')
}

// 定时器
const TIMEER_timer = (value) => {
    let tiem = new Date(value).getTime()
    let newTiem = new Date().getTime();
    let a = 24 * 60 * 60 * 1000;
    let item = ""
    let obsolete = ""
    item = tiem + a;
    if (newTiem > item) {
        obsolete = "过时";
    } else {
        item = item - newTiem;
        let d = parseInt(item / (24 * 60 * 60 * 1000));
        d = d < 10 ? "0" + d : d;
        let h = parseInt((item / (60 * 60 * 1000)) % 24);
        h = h < 10 ? "0" + h : h;
        let m = parseInt((item / (60 * 1000)) % 60);
        m = m < 10 ? "0" + m : m;
        let s = parseInt((item / 1000) % 60);
        s = s < 10 ? "0" + s : s;
        obsolete = h + "时" + m + "分" + s + "秒";
    }
    return obsolete
}

const timer = () => {
    return
}

// 结算方式
const PAYMENT = (value) => {
    let payment_method_type = JSON.parse(window.localStorage.getItem("payment_method_type")) || []
    const arr = payment_method_type.filter(item => {
        return item.value == value
    })
    return arr.length > 0 ? arr[0].description : ''
}
// 货物类型
const TypeGoods = (value) => {
    let good_type = JSON.parse(window.localStorage.getItem("good_type")) || []
    const arr = good_type.filter(item => {
        return item.value == value
    })
    return arr.length > 0 ? arr[0].description : ''
}


// 装卸方式
const UNLOADING = (value) => {
    let UNLOADING = JSON.parse(window.localStorage.getItem("loading_unloading_mode")) || []
    const arr = UNLOADING.filter(item => {
        return item.value == value
    })
    return arr.length > 0 ? arr[0].description : ''
}

// 装卸方式
const VEHICLENEWTYPE = (value) => {
    let UNLOADING = JSON.parse(window.localStorage.getItem("vehicle_new_type")) || []
    const arr = UNLOADING.filter(item => {
        return item.value == value
    })
    return arr.length > 0 ? arr[0].description : ''
}

// 能源类型
const OILTYPE = (value) => {
    if (value) {
        let UNLOADING = JSON.parse(window.localStorage.getItem("oil_type")) || []
        const arr = UNLOADING.filter(item => {
            return item.value == value
        })
        return arr.length > 0 ? arr[0].description : ''
    }

}

const ORDER_STATE = (value) => {
    let state = "";
    switch (value) {
        case -1:
            return '已取消';
            break;
        case 0:
            state = '驾驶员接单';
            break;
        case 1:
            state = "确认装货";
            break;
        case 2:
            state = "确认卸货";
            break;
        case 3:
            state = "审核通过";
            break;
        case 4:
            state = "确认支付";
            break;
        case 5:
            state = "已签收";
            break;
        default:
            state = "未知";
    }
    return state;
}

const ORDER_STATE_CH = (value) => {
    let state = "";
    switch (value) {
        case -1:
            return '已取消'
            break;
        case 0:
            state = '驾驶员接单'
            break;
        case 1:
            state = "确认装货";
            break;
        case 2:
            state = "确认卸货";
            break;
        case 3:
            state = "待审核(货主)";
            break;
        case 4:
            state = "待审核(货主)";
            break;
        case 5:
            state = "已签收";
            break;
            break;
        default:
            state = "未知";
    }
    return state;
}

const DATA_TIME = (val) => {
    let date = new Date(val);
    let y = 1900 + date.getYear();
    let m = "0" + (date.getMonth() + 1);
    let d = "0" + date.getDate();
    return y + m.substring(m.length - 2, m.length) + d.substring(d.length - 2, d.length);
}
const MUNBER = (val) => {
    let num = 0
    if (val == 0) {
    } else {
        num = val / 10000
    }
    if (num > 0.000001) {
        num.toFixed(2)
    } else {
        num = 0
    }
    return num.toFixed(2)
}


export default {
    timer,
    SOURCE_STATUS,
    SOURCE_DETAIL_STATUS,
    ORDER_SOURCE_STATUS,
    ORDER_STATUS,
    REGIST_STATUS,
    VEHICLE_LENGTH_TYPE,
    MODEL_REQUIRED,
    VEHICLE_TYPE,
    REQUIRED_VEHILE_LENGTH,
    GOOD_NEY_TYPE,
    GOOD_NEY_TYPE_CARRY,
    ORDER_STATE,
    PAYMENT,
    TypeGoods,
    UNLOADING,
    DATA_TIME,
    VEHICLENEWTYPE,
    OILTYPE,
    ORDER_STATUS_CH,
    ORDER_STATE_CH,
    TIMEER_timer,
    VEHICLE_COLOR,
    MUNBER,
    BANK_CARD_TYPE
}